package com.nai365.nart.operation.service.impl;

import com.nai365.nart.common.core.constant.SecurityConstants;
import com.nai365.nart.common.core.util.R;
import com.nai365.nart.operation.service.OrderService;
import com.nai365.nart.order.api.feign.OrderFeignService;
import com.nai365.nart.order.entity.OrderItem;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Service
@RequiredArgsConstructor
public class OrderServiceImpl implements OrderService {

	private final OrderFeignService orderFeignService;

	@Override
	public List<OrderItem> findPayedBySkuIdList(Collection<Long> idList) {
		R<List<OrderItem>> remote = orderFeignService.findPayedBySkuIdList(idList, SecurityConstants.FROM_IN);
		List<OrderItem> orderItemList = new ArrayList<>();
		if (remote.getCode() == 0 && remote.getData() != null) {
			orderItemList = remote.getData();
		}
		return orderItemList;
	}
}
